<html class="no-js" lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title>Dashboard V.1 | Kiaalap - Kiaalap Admin Template</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- favicon
		============================================ -->
    <link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico">
    <!-- Google Fonts
		============================================ -->
    <link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,700,900" rel="stylesheet">
    <!-- Bootstrap CSS
		============================================ -->
    <link rel="stylesheet" href="css/bootstrap.min.css">

    <!-- Lobibox CSS
        ============================================ -->
    <link rel="stylesheet" href="css/notifications/Lobibox.min.css">

    <!-- Bootstrap CSS
		============================================ -->
    <link rel="stylesheet" href="css/font-awesome.min.css">


    <!-- DatetimePicker CSS
        ============================================ -->
    <link rel="stylesheet" href="css/datetimepicker/bootstrap-datetimepicker.min.css">

    <!-- owl.carousel CSS
		============================================ -->
    <link rel="stylesheet" href="css/owl.carousel.css">
    <link rel="stylesheet" href="css/owl.theme.css">
    <link rel="stylesheet" href="css/owl.transitions.css">
    <!-- animate CSS
		============================================ -->
    <link rel="stylesheet" href="css/animate.css">
    <!-- normalize CSS
		============================================ -->
    <link rel="stylesheet" href="css/normalize.css">
    <!-- meanmenu icon CSS
		============================================ -->
    <link rel="stylesheet" href="css/meanmenu.min.css">
    <!-- main CSS
		============================================ -->
    <link rel="stylesheet" href="css/main.css">
    <!-- educate icon CSS
		============================================ -->
    <link rel="stylesheet" href="css/educate-custon-icon.css">
    <!-- morrisjs CSS
		============================================ -->
    <link rel="stylesheet" href="css/morrisjs/morris.css">
    <!-- mCustomScrollbar CSS
		============================================ -->
    <link rel="stylesheet" href="css/scrollbar/jquery.mCustomScrollbar.min.css">
    <!-- metisMenu CSS
		============================================ -->
    <link rel="stylesheet" href="css/metisMenu/metisMenu.min.css">
    <link rel="stylesheet" href="css/metisMenu/metisMenu-vertical.css">
    <!-- calendar CSS
		============================================ -->
    <link rel="stylesheet" href="css/calendar/fullcalendar.min.css">
    <link rel="stylesheet" href="css/calendar/fullcalendar.print.min.css">

    <!-- form CSS
		============================================ -->
    <link rel="stylesheet" href="css/form/all-type-forms.css">

    <!-- style CSS
		============================================ -->
    <link rel="stylesheet" href="css/style.css">
    <!-- responsive CSS
		============================================ -->
    <link rel="stylesheet" href="css/responsive.css">
    <!-- modernizr JS
		============================================ -->
    <script src="js/jquery.min.js"></script>

    <script src="js/vendor/modernizr-2.8.3.min.js"></script>
    <script src="js/vue.js"></script>



</head>

<body>
<!--[if lt IE 8]>
<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade
    your browser</a> to improve your experience.</p>
<![endif]-->
<!-- Start Left menu area -->
<div class="left-sidebar-pro">
    <nav id="sidebar" class="">
        <div class="sidebar-header">
            <a href="index.html"><img class="main-logo" src="img/logo/logo.png" alt=""/></a>
            <strong><a href="index.html"><img src="img/logo/logosn.png" alt=""/></a></strong>
        </div>
        <div class="left-custom-menu-adp-wrap comment-scrollbar">
            <nav class="sidebar-nav left-sidebar-menu-pro">
                <ul class="metismenu" id="menu1">
                    <li class="active">
                        <a class="has-arrow" href="index.html">
                            <span class="fa fa-id-card"></span>
                            <span class="mini-click-non">用户信息</span>
                        </a>
                        <ul class="submenu-angle" aria-expanded="true">
                            <li><a href="dataStatistics.html"><span class="mini-sub-pro">图表信息统计</span></a></li>
                            <li><a href="index.html"><span class="mini-sub-pro">用户列表</span></a></li>
                            <li><a href="goodsManager.html"><span class="mini-sub-pro">商品列表</span></a></li>
                            <li><a href="order.html"><span class="mini-sub-pro">订单管理</span></a></li>
                            <li><a href="payPage.html"><span class="mini-sub-pro">支付流水列表</span></a></li>
                            <li><a href="logManagement.html"><span class="mini-sub-pro">日志管理</span></a></li>
                            <li><a href="dataPush.html"><span class="mini-sub-pro">级光推送</span></a></li>

                        </ul>
                    </li>
                    <li>
                        <a title="Landing Page" href="sysUser.html" aria-expanded="false"><span
                                class="fa fa-user-circle-o" aria-hidden="true"></span> <span
                                class="mini-click-non">系统用户</span></a>
                    </li>

                </ul>
            </nav>
        </div>
    </nav>
</div>
<!-- End Left menu area -->
<!-- Start Welcome area -->
<div class="all-content-wrapper">
    <div class="container-fluid">
        <div class="row">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <div class="logo-pro">
                    <a href="index.html"><img class="main-logo" src="img/logo/logo.png" alt=""/></a>
                </div>
            </div>
        </div>
    </div>
    <div class="header-advance-area">
        <div class="header-top-area">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                        <div class="header-top-wraper">
                            <div class="row">
                                <div class="col-lg-1 col-md-0 col-sm-1 col-xs-12">
                                    <div class="menu-switcher-pro">
                                        <button type="button" id="sidebarCollapse"
                                                class="btn bar-button-pro header-drl-controller-btn btn-info navbar-btn">
                                            <i class="fa fa-bars"></i>
                                        </button>
                                    </div>
                                </div>
                                <div class="col-lg-6 col-md-7 col-sm-6 col-xs-12">
                                    <div class="header-top-menu tabl-d-n">
                                        <ul class="nav navbar-nav mai-top-nav">
                                            <li class="nav-item"><a href="#" class="nav-link"></a>
                                            </li>
                                            <li class="nav-item"><a href="#" class="nav-link"></a>
                                            </li>
                                            <li class="nav-item"><a href="#" class="nav-link"></a>
                                            </li>
                                            <li class="nav-item dropdown res-dis-nn">

                                                <div role="menu" class="dropdown-menu animated zoomIn">
                                                    <a href="#" class="dropdown-item">Documentation</a>
                                                    <a href="#" class="dropdown-item">Expert Backend</a>
                                                    <a href="#" class="dropdown-item">Expert FrontEnd</a>
                                                    <a href="#" class="dropdown-item">Contact Support</a>
                                                </div>
                                            </li>
                                            <li class="nav-item"><a href="#" class="nav-link"></a>
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                                <div class="col-lg-5 col-md-5 col-sm-12 col-xs-12">
                                    <div class="header-right-info">
                                        <ul class="nav navbar-nav mai-top-nav header-right-menu">
                                            <li class="nav-item">
                                                <a href="#" data-toggle="dropdown" role="button" aria-expanded="false"
                                                   class="nav-link dropdown-toggle">


                                                    <span class="admin-name" id="admin-name">用户管理</span>
                                                    <span class="admin-name2" id="admin-nam2"></span>
                                                </a>
                                                <ul role="menu"
                                                    class="dropdown-header-top author-log dropdown-menu animated zoomIn">
                                                    <li><a href="sysUser.html"><span
                                                            class="edu-icon edu-home-admin author-log-ic"></span><button>管理员信息</button></a>
                                                    <li><a><span
                                                            class="edu-icon edu-settings author-log-ic"></span><button  onclick="loginOut()">切换登录</button></a>
                                                    <li><a><span
                                                            class="edu-icon edu-settings author-log-ic" ></span><button onclick="loginOut()">退出登录</button>
                                                    </a></li>

                                                </ul>
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="container-fluid" style="padding: 20px 15px 0 15px;">

            <!-- 订单页面 -->

            <form class="form-inline" onsubmit="javascript: return false;">
                <div class="form-group">
                    <label for="orderNumber">订单号: </label>
                    <input autocomplete="off" class="form-control" id="orderNumber">
                </div>
                <div class="form-group">
                    <label for="goods">商品: </label>
                    <input autocomplete="off" class="form-control" id="goods">
                </div>
                <div class="form-group">
                    <label for="status">订单状态: </label>
                    <select class="form-control" id="status">
                        <option value="-1">全部</option>
                        <option value="0">未支付</option>
                        <option value="1">已支付</option>
                        <option value="2">已取消</option>
                    </select>
                </div>
                <div class="form-group">
                    <label>注册日期: </label>
                    <input class="form-control" readonly autocomplete="off" id="beginRegisterDate"> -
                    <input autocomplete="off" readonly class="form-control" id="endRegisterDate">
                </div>
                <div class="form-group">
                    <button class="btn btn-danger" onclick="querySearch()">搜索</button>
                    <button autocomplete="off" class="btn btn-danger" onclick="resetSearch()">重置</button>
                </div>
            </form>

            <table id="goodsDataTable" class="table table-bordered table-striped"></table>

            <div class="modal" id="addGoodsModal" data-backdrop="static">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button onclick="destoryAddGoodsModal()" class="close">
                                <span>&times;</span>
                            </button>
                            <h3 class="modal-title">用户信息</h3>
                        </div>
                        <div class="modal-body">
                            <form>
                                <input type="hidden" id="imageServerPath">
                                <div class="form-group">
                                    <label for="title">买家</label>
                                    <input class="form-control" autocomplete="off" id="title" disabled="disabled" value="45645">
                                </div>
                                <div class="form-group">
                                    <label for="items">买家电话</label>
                                    <input class="form-control" autocomplete="off" id="items" disabled="disabled" value="45645">
                                </div>

                                <div class="form-group">
                                    <label for="price">买家地址</label>
                                    <input class="form-control" autocomplete="off" id="price" disabled="disabled">
                                </div>

                            </form>
                        </div>
                        <div class="modal-footer">
                            <button onclick="destoryAddGoodsModal()" class="btn btn-danger">取消</button>

                        </div>
                    </div>
                </div>
            </div>


            <div class="modal" id="changeOrders" data-backdrop="static">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button onclick="destoryAddGoodsModal01()" class="close">
                                <span>&times;</span>
                            </button>
                            <h3 class="modal-title">改变地址</h3>
                        </div>
                        <div class="modal-body">
                            <form>
                                <input type="hidden" id="imageServerPath0">
                                <div class="form-group">
                                    <label for="title01">原地址</label>
                                    <input class="form-control" autocomplete="off" id="title01" disabled="disabled" >

                                    <table class="table table-hover table-bordered table-striped" id="dataTable">
                                        <thead>
                                        <tr>
                                            <th>现地址</th>
                                        </tr>
                                        </thead>
                                        <tbody id="users">
                                        <tr v-for ="a in addresses" >

                                            <td><input type="radio" name="type00" :value="a.aid" onclick="getpages(this)">{{a.address}}</td>
                                        </tr>

                                        </tbody>
                                    </table>
                                </div>
                            </form>
                        </div>
                        <div class="modal-footer">
                            <button onclick="destoryAddGoodsModal01()" class="btn btn-danger">取消</button>
                            <button class="btn btn-success" onclick="changeAddress()">确认</button>
                        </div>
                    </div>
                </div>
            </div>


                        <!-- 尾部页面 -->

        </div>
    </div>
    </div>

    <!-- jquery
    ============================================ -->
    <script src="js/vendor/jquery-1.12.4.min.js"></script>
    <!-- bootstrap JS
    ============================================ -->
    <script src="js/bootstrap.min.js"></script>
    <!-- wow JS  动画效果js
    ============================================ -->
    <script src="js/wow.min.js"></script>
    <!-- price-slider JS
    ============================================ -->
    <script src="js/jquery-price-slider.js"></script>
    <!-- meanmenu JS
    ============================================ -->
    <script src="js/jquery.meanmenu.js"></script>
    <!-- owl.carousel JS
    ============================================ -->
    <script src="js/owl.carousel.min.js"></script>
    <!-- sticky JS
    ============================================ -->
    <script src="js/jquery.sticky.js"></script>
    <!-- scrollUp JS
    ============================================ -->
    <script src="js/jquery.scrollUp.min.js"></script>
    <!-- counterup JS
    ============================================ -->
    <script src="js/counterup/jquery.counterup.min.js"></script>
    <script src="js/counterup/waypoints.min.js"></script>
    <script src="js/counterup/counterup-active.js"></script>
    <!-- mCustomScrollbar JS
    ============================================ -->
    <script src="js/scrollbar/jquery.mCustomScrollbar.concat.min.js"></script>
    <script src="js/scrollbar/mCustomScrollbar-active.js"></script>
    <!-- metisMenu JS
    ============================================ -->
    <script src="js/metisMenu/metisMenu.min.js"></script>
    <script src="js/metisMenu/metisMenu-active.js"></script>


    <script src="js/sparkline/jquery.sparkline.min.js"></script>
    <script src="js/sparkline/jquery.charts-sparkline.js"></script>
    <script src="js/sparkline/sparkline-active.js"></script>
    <!-- calendar JS
    ============================================ -->
    <script src="js/calendar/moment.min.js"></script>

    <script src="js/calendar/fullcalendar.min.js"></script>
    <script src="js/calendar/fullcalendar-active.js"></script>
    <!-- plugins JS
    ============================================ -->
    <script src="js/plugins.js"></script>
    <!-- main JS
    ============================================ -->
    <script src="js/main.js"></script>

    <!-- tawk chat JS  聊天系统js
    <script src="js/tawk-chat.js"></script>
    ============================================ -->

    <script src="js/data-table/bootstrap-table.js"></script>
    <script src="js/data-table/bootstrap-table-zh-CN.js"></script>

    <script src="js/notifications/Lobibox.js"></script>
    <script src="js/datepicker/bootstrap-datetimepicker.min.js"></script>
    <script src="js/datepicker/bootstrap-datetimepicker.zh-CN.js"></script>
    <script src="js/jquery.cookie.min.js"></script>
<script src="js/login-status.js"></script>

    </body>
    <script>
        var goodsId01;
        var goodsId02;

        var vm = new Vue({
            el:'#dataTable',
            data:{
                addresses:[]
            }
        })

        //显示订单管理全部信息
        $('#goodsDataTable').bootstrapTable({

            url: 'http://localhost:8080/order',
            method: 'GET',
            columns: [
                // field是返回rows中每个对象的属性名
                {title: '订单ID', field: 'o_id', align: 'center'},
                {title: '订单号', field: 'o_no'},
                {title: '商品', field: 'o_good_title',formatter: formatTitle },
                {title: '订单价格', field: 'o_good_price'},
                {title: '订单数量', field: 'o_num'},
                {title: '订单状态', field: 'o_status',formatter: formatStatus,align: 'center'},
                {title: '下单日期', field: 'o_create_time',formatter: formatTime},
                {title: '操作',formatter: addProcessBtn}
            ],
            queryParams: function (params) {

                var orderNumber = $('#orderNumber').val();  //获取查询表单name的值
                var goods = $('#goods').val();
                var status = $('#status').val();
                var begin = $('#beginRegisterDate').val(); //重置name
                var end = $('#endRegisterDate').val(); //重置name

                params.orderNumber = orderNumber;
                params.goods = goods;
                params.status = status;
                params.begin = begin;
                params.end = end;
                return params;
            },
            sidePagination: 'server',
            pagination: true, //表示使用分页
        })



        //获取订单对应用户的信息
        function getUserAddress(o_id) {

            $('#title').val('');
            $('#items').val('');
            $('#price').val('');

            $.ajax({
                url: 'http://localhost:8080/order/'+o_id,
                type: 'get',
                dataType: 'json',
                success: function(_data) {
                    $('#title').val(_data.orderAddress.a_name)
                    $('#items').val(_data.orderAddress.a_phone)
                    $('#price').val(_data.orderAddress.a_detail)
                }
            })


            $('#addGoodsModal').modal('show');
        }


        //展示订单的收获地址
        function changeOrderAddress(o_id,u_id,a_id) {
            // console.log(a_id);
            //
            //
            // var uid =$('#imageServerPath0').val(a_id);
            //
            // console.log(uid);
            goodsId01=a_id;


            $.ajax({
                // url: "http://localhost:8080/address",
                url: 'http://localhost:8080/order/'+o_id,
                type: 'get',
                dataType: 'json',
                success: function(_data) {

                    $('#title01').val( _data.orderAddress.a_detail)
                }
            })

            //展示订单的可选地址
            vm.addresses=[];
            $.ajax({
                url: 'http://localhost:8080/order/uid/'+u_id,
                type:'get',
                dataType:'json',
                success:function (_data) {
                    for(var i = 0; i < _data.length; i++) {

                        vm. addresses.push(_data[i])

                    }

                }
            })


            $('#changeOrders').modal('show');

        }

        function getpages(btnTag) {
            var aid = $(btnTag).attr('value');
            goodsId02 = aid;
        }

        //改变收获地址
        function changeAddress() {

            var uid= goodsId01;

            var aid =goodsId02;
            $.ajax({
                url: 'http://localhost:8080/order/changeOrder/'+aid+'/'+uid,
                type:'get',
                dataType:'json',
                success:function (_data) {

                    if(_data.code == 1){
                        destoryAddGoodsModal01()
                        $('#goodsDataTable').bootstrapTable('refresh');
                    }

                }
            })
        }







        // 添加操作按钮
        function addProcessBtn(value, row) {


            //订单id
            var goodsId001 =row.o_id;

            //用户对应u_id
            var goodsId003 = row.orderAddress.u_id;

            //用户对应的a_id
            var aid = row.orderAddress.a_id;

            return[
                '<button onclick="getUserAddress(' + goodsId001 + ')" class="btn btn-danger btn-xs">查看详情</button>&nbsp&nbsp;',
                '<button onclick="changeOrderAddress(' + goodsId001 + ',\''+goodsId003+'\',\''+aid+'\')" class="btn btn-primary btn-xs">改变地址</button>'
            ].join("")

        }

        // 格式化日期
        function formatTime(value) {
            return moment(value).format('YYYY-MM-DD HH:mm:ss')
        }

        //订单状态
        function formatStatus(value, rows) {
            if (value ==0){
                return '<span class="label label-warning">未支付</span>'
            }else if (value ==1){
                return '<span class="label label-success">已支付</span>'

            }else if (value ==2){
                return '<span class="label label-danger">已取消</span>'

            }else if (value ==3){
                return '<span class="label label-success">已过期</span>'

            }else if (value ==4){
                return '<span class="label label-success">退款中</span>'

            }else if (value ==5){
                return '<span class="label label-success">退款成功</span>'

            }else if (value ==6){
                return '<span class="label label-success">发货中</span>'

            }

        }


        //当内容长度大于30的时候，多余的不显示
        function formatTitle(value) {
            var length = value.length; //获取文本长度
            if(length > 20) {
                return value.substring(0, 20) + '...';
            }
            return value;
        }

        // 隐藏模态框
        function destoryAddGoodsModal() {

            $('#addGoodsModal').modal('hide');
        }

        // 隐藏模态框
        function destoryAddGoodsModal01() {

            $('#changeOrders').modal('hide');
        }

        $('#beginRegisterDate, #endRegisterDate').datetimepicker({
            // 格式化 yyyy-mm-dd hh:ii:ss 年-月-日 时-分-秒
            format: 'yyyy-mm-dd hh:ii:ss'
        })

        // 搜索
        function querySearch() {
            $('#goodsDataTable').bootstrapTable('refresh');
        }

        function resetSearch() {
            $('#orderNumber').val(''); //重置name
            $('#goods').val(''); //重置性别
            $('#status').val('-1'); //重置状态
            $('#beginRegisterDate').val('');
            $('#endRegisterDate').val('');
            querySearch();
        }
        function loginOut(){

            $.ajax({
                url:'http://localhost:8080/sysUser/loginOut',
                method:'get',
                success:function (_data) {
                    alert(_data.msg);
                    $.cookie('frontedUsername','',path='/');
                    window.location="/shop/login.html";
                }

            })
        }
        $('#admin-name').hide();
        $('#admin-nam2').html('欢迎你'+$.cookie('frontedUsername'));
    </script>
    </html>